package com.mr.example;

import com.mr.core.*;

public class WordCountReducer implements Reducer<String, Integer, String, Integer> {
    @Override
    public void reduce(String key, Iterable<Integer> values, Context<String, Integer> context) {
        // 累加相同单词的出现次数
        int sum = 0;
        for (Integer count : values) {
            sum += count;
        }
        context.write(key, sum); // 输出单词总次数
    }
}